package com.itgungnir.designpattern.flyweight;

public class Test {
	public static void main(String[] args) {
		MyChar char1;
		MyChar char2;
		MyChar char3;
		MyChar char4;
		MyChar char5;
		MyChar char6;

		char1 = MyCharFactory.getInstance().getMyChar(new Character('a'));
		System.out.println("获取享元字符：" + char1.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
		char2 = MyCharFactory.getInstance().getMyChar(new Character('b'));
		System.out.println("获取享元字符：" + char2.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
		char3 = MyCharFactory.getInstance().getMyChar(new Character('c'));
		System.out.println("获取享元字符：" + char3.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
		char4 = MyCharFactory.getInstance().getMyChar(new Character('a'));
		System.out.println("获取享元字符：" + char4.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
		char5 = MyCharFactory.getInstance().getMyChar(new Character('a'));
		System.out.println("获取享元字符：" + char5.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
		char6 = MyCharFactory.getInstance().getMyChar(new Character('d'));
		System.out.println("获取享元字符：" + char6.showMyChar());
		System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());
	}
}